import request from '../utils/request.js'
import {
	formDataString
} from '../utils/tools.js'

// 有赞商城分页订单获取
export const yzQueryPageList = function(data) {
	return request({
		// 经销商登录
		url: '/yz/queryPageList',
		method: 'POST',
		data
	})
}

// 有赞商城订单详情信息获取
export const getYzOrderDetailPage = function(tid) {
	return request({
		// 经销商登录
		url: '/yz/getYzOrderDetail?tid='+tid,
		method: 'POST',
	})
}

// 有赞订单商城订单确认
export const getYzStatusOrder = function(data) {
	return request({
		// 经销商登录
		url: '/yz/saveYzTradeAgentOperation',
		method: 'POST',
		data
	})
}

export const agentServerLogin = function(data) {
	return request({
		// 经销商登录
		url: '/port/emp/agentLogin',
		method: 'POST',
		data
	})
}

export const agentRegister = function(data) {
	return request({
		// 经销商绑定
		url: '/port/emp/appBind',
		method: 'POST',
		data
	})
}

export const agentStaffServerLogin = function(data) {
	return request({
		// 员工登录
		url: '/port/emp/staffLogin',
		method: 'POST',
		data
	})
}

export const agentStaffRegister = function(data) {
	return request({
		// 员工绑定
		url: '/port/emp/staffAppBind',
		method: 'POST',
		data
	})
}

export const getAgentCode = function(data) {
	return request({
		// 团队扫码
		url: '/miniapp/createWxaCodeUnlimitBytes',
		method: 'POST',
		data
	})
}

export const staffBindAgent = function(data) {
	return request({
		// 扫码注册
		url: '/port/emp/registScanQrCode',
		method: 'POST',
		data
	})
}

export const getLeader = function(data) {
	return request({
		// 团队负责人下的员工列表
		url: '/port/emp/getParentEmp',
		method: 'POST',
		data
	})
}

export const getStaffList = function(data) {
	return request({
		// 经销商列表
		url: '/port/emp/getStaffEmpList',
		method: 'POST',
		data
	})
}

export const unBindStaff = function(data) {
	return request({
		// 团队解绑
		url: '/port/emp/unBindRelation',
		method: 'POST',
		data
	})
}

// 粉丝管理列表
export const getFansList = function(data) {
	return request({
		url: '/port/emp/queryFansByFkDept',
		method: 'POST',
		data
	})
}

// 分页查询粉丝queryCustomerByFkDept
export const getFansPageList = function(data) {
	return request({
		url: '/port/emp/queryCustomerByFkDept',
		method: 'POST',
		data
	})
}

// 判断粉丝是否客户/port/emp/queryFansIsCustomer 传参：open_id=xxx
export const getFansIsCustomer = function(open_id) {
	return request({
		url: '/port/emp/queryFansIsCustomer?open_id='+open_id,
		method: 'GET',
	})
}

export const getTodoList = function(data) {
	let t = Math.random()
	return request({
		// 流程待办方法
		url: `/WF/Comm/ProcessRequest?DoType=HttpHandler&DoMethod=Todolist_Init&HttpHandlerName=BP.WF.HttpHandler.WF&t=${t}`,
		method: 'POST',
		data
	})
}

export const staffPass = function(data) {
	return request({
		// 未处理 通过
		url: '/port/emp/todoPass',
		method: 'POST',
		data
	})
}

export const staffNotPass = function(data) {
	return request({
		// 拒绝处理状态
		url: '/port/emp/todoRefuse',
		method: 'POST',
		data
	})
}



// 单次上传图片 可以循环用
export const appointOrderApiUrl = '/hr/gongdan/saveHrGongdanAppoint'
// 上传图片
export const appointPicOrderApiUrl ='/hr/gongdan/uploadPicHrGongdanAppoint'

 

// 实时更新预约单 /hr/gongdan/updateHrGongdanAppoint 
export const updateSaveAppointOrder = function(data) {
	return request({
		url: '/hr/gongdan/updateHrGongdanAppoint',
		method: 'POST',
		data
	})
}

// 删除list内容 /hr/gongdan/deleteHrGongdanAppoint
export const deleteListAppointOrder = function(id){
	return request({
		url: '/hr/gongdan/deleteHrGongdanAppoint?id='+id,
		method: 'get',
	})
}

//可用 旧的工单提交 不上传图片可用 新增预约单  saveAppointOrder
export const saveAppointOrder = function(data) {
	return request({
		
		url: '/hr/gongdan/saveHrGongdanAppoint',
		method: 'POST',
		header: {
			'content-type': 'multipart/form-data; boundary=XXX'
		},
		data: formDataString(data)
	})
}

// 获取预充值接口
export const _appointPrePrice=function(No){
	// return request({
	// 	url: '/hr/finance/sumRemaining',
	// 	method: 'POST',
	// 	data
		return request({
		   url: '/hr/finance/sumRemaining?no=' + No,
		   method: 'get',
	})
}


// 获取每个item的详情数据截取id
export const getOrderItemDetail=function(orderNumber){
		return request({
		   url: '/hr/gongdan/queryPageListAppointByOrderNumber?orderNumber='+orderNumber,
		   method: 'get',
	})
}

// 预约单信息保存 存为草稿状态
// export const appointOrderApiUrl = '/hr/gongdan/saveHrGongdanAppoint'

// 发起单（预约单id) 提交的时候 把预约订单状态改成提交状态=已提交 
export const getPreOrder=function(data){
	return request({
		url: '/hr/gongdan/updateHrGongdanAppointSubmit',
		method: 'POST',
		data
	})
}

// 代理商查询自己预约单 有范围 发起单的列表
export const getAppointList = function(data) {
	return request({
		url: '/hr/gongdan/queryPageListAppointAgent',
		method: 'POST',
		data
	})
}

export const getShopsList = function(data) {
	return request({
		// 门店管理 店面展示
		url: '/wxcms/getShops',
		method: 'POST',
		data
	})
}

export const getAgentCode2 = function(data) {
	return request({
		// 生成公众号状态二维码 每一个代理商都有唯一二维码
		// 记录谁进入
		url: '/mp/qrCodeCreateLastTicket',
		method: 'POST',
		data
	})
}

export const getEmpList = function(data) {
	return request({
		// 根据团队编码查询员工列表
		url: '/port/emp/getStaffEmpListByTeamNo',
		method: 'GET',
		data
	})
}

export const getShopsShowPic = function(data) {
	return request({
		// 展示门店
		url: '/media/getShopMedia',
		method: 'POST',
		data
	})
}

export const getAgentByTeamNo = function(data) {
	return request({
		// 电子台账 jxc开头都是
		url: '/jxc/getPortEmpByTeamNo',
		method: 'POST',
		data
	})
}

